package mmc.server.shell.ops.utility;

import mmc.server.Player;
import mmc.server.Server;
import mmc.server.shell.OperationNotAcceptedException;
import mmc.server.shell.ShellException;
import mmc.server.shell.ops.Constant;

public class PlayerLink extends Constant {

	private Player player;
	
    public PlayerLink(String text) throws ShellException {
    	super(text = text.trim());

    	for(Player p : Server.instance.getScene().getPlayers()){
    		if(p.getName().equalsIgnoreCase(text)){
    			player = p;
    			return;
    		}
    	}
    	
    	throw new OperationNotAcceptedException(false, "not a player-name: "+text);
    }

    @Override
    public double execute() {
    	throw new RuntimeException(this+" has no double output!");
    }
    
    @Override
    public Object executeComplex(){
    	return player;
    }
    
    @Override
    public Class<?> getOutputType(){
    	return Player.class;
    }
    
    public static boolean hideInDescription(){
    	return true;
    }
}
